package com.gxuwz.medical.dao;

import java.sql.ResultSet;

import java.sql.SQLException;

import com.gxuwz.medical.domain.chronicdis.Chronicdis;
import com.gxuwz.medical.domain.chronicinfo.ChronicInfo;
import com.gxuwz.medical.domain.person.Person;
import com.gxuwz.medical.exception.PersonNotFoundException;

public class ChronicInfoDao extends GenericDao<ChronicInfo> {
	@Override
	protected ChronicInfo handle(ResultSet rs) throws SQLException {
		
		ChronicInfo entity=new ChronicInfo();
		entity.setId(rs.getString("id"));
		entity.setCreator(rs.getString("creator"));
		entity.setCreattime(rs.getDate("creattime"));
		entity.setStarttime(rs.getString("starttime"));
		entity.setEndtime(rs.getString("endtime"));
		entity.setStatus(rs.getString("status"));
		try {
			entity.setPerson(new Person(rs.getString("perscode")));
			try {
				entity.setChronicdis(new Chronicdis(rs.getString("illcode")));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (PersonNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return entity;
		/**
		 *  pstmt.setString(index++, this.id);
			  pstmt.setString(index++, this.getPerson().getPerscode());
			  pstmt.setString(index++, this.chronicdis.getIllcode());
			  pstmt.setString(index++, this.starttime);
			  pstmt.setString(index++, this.endtime);
			  pstmt.setString(index++, this.status);
			  pstmt.setDate(index++, new java.sql.Date(this.creattime.getTime()));
			  pstmt.setString(index++, this.creator);
		 */
	}
}
